while ((playp+BUFBLOCK<=readp) && !done) condition_wait(sync_threads,position);
rp=readp; pp=playp;
ep=rp+READBLOCK;
if (ep>endframe) ep=endframe;
if (rp%BUFBLOCK+(ep-rp)>BUFBLOCK) ep=rp+BUFBLOCK-(rp%BUFBLOCK);
if (pp+BUFBLOCK<ep) ep=pp+BUFBLOCK;
if (ep>rp)
{
mutex_unlock(position);
if (scsiread10(buf+(rp%BUFBLOCK)*BLOCKSIZE,(ep-rp)*BLOCKSIZE,0x28,0,0,0,0,0,(BCD((rp+offset)/(75*60))<<24)+(BCD(((rp+offset)/75)%60)<<16)+(BCD((rp+offset)%75)<<8),0,ep-rp,1<<6)) goto end;
mutex_lock(position);
rp=readp=ep;
condition_broadcast(sync_threads);
}
}
mutex_unlock(position);
}
end:
done=1;
condition_broadcast(sync_threads);
cthread_join(play_t);
if (scsiwrite6s(&opage,sizeof(opage),0x15,0,0,0,sizeof(opage),0))